package com.springboot.frame.controller;

import com.springboot.frame.domain.EnumTest;
import com.springboot.frame.enums.PersonType;
import com.springboot.frame.mapper.EnumTestMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author liheng
 * @ClassName IndexController
 * @Description
 * @date 2020-12-28 11:31
 */
@RestController
@RequestMapping("/")
public class IndexController {
    @Autowired
    private EnumTestMapper enumTestMapper;

    @RequestMapping
    public PersonType index(){
      return   PersonType.getEnum("a");
    }

    @RequestMapping("add")
    public EnumTest index(@Validated @RequestBody EnumTest type){
        enumTestMapper.insert(type);
        return  type;
    }

    @RequestMapping("sel/{id}")
    public EnumTest sel(@PathVariable Integer id){
        return  enumTestMapper.selectById(id);
    }
}
